package org.xiaojl.utils;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * JSON处理的工具类
 */
public class JsonUtil {
	private static final Logger log = LoggerFactory.getLogger(JsonUtil.class);
	
	public static String obj2str(Object obj){
		Gson gson = new GsonBuilder().create();
		String res = gson.toJson(obj);
		return res;
	}
	
	@SuppressWarnings("unchecked")
	public static Map<String,String> str2Map(String json){
		Gson gson = new GsonBuilder().create();
		return gson.fromJson(json, Map.class);
	}
	
}
